import React, { Component } from 'react';
import "../assets/css/PageHeader.css";
import {withRouter} from "react-router-dom"

class PageHeader extends Component {
    constructor(props) {
        super(props)
    
        this.state = {
             
        }
        this.ToBack = this.ToBack.bind(this)
    }

    ToBack(){
        this.props.history.goBack();
    }
    render() {
        var slots= {}
        var children = Array.isArray(this.props.children) ? this.props.children : [this.props.children]
        children.forEach(item=>{
            slots[item.props.slot] = item
        })
        return (
            <div className="PageHeader">
                <div className="GoBack" onClick={this.ToBack}>
                    <i></i>
                    <span>返回</span>
                </div>
                <div className="title">{slots["title"]}</div>
                <div className="right">{slots["right"]}</div>
            </div>
        );
    }
}

export default withRouter(PageHeader);